<template>
    <div class="app-container">
      <el-form :model="queryParams" class="frominfo" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="108px">
        <div class="from-item">
            <el-form-item label="微信名称" prop="wcUserName">
              <el-input v-model="queryParams.wcUserName" @keyup.enter.native="handleQuery" placeholder="请输入好友微信名称" clearable/>
            </el-form-item>
            <el-form-item label="好友所属人员" prop="wcName">
              <el-input v-model="queryParams.wcName" @keyup.enter.native="handleQuery" placeholder="请输入所属人员" clearable/>
            </el-form-item>
            <el-form-item label="微信ID" prop="wcId">
              <el-input v-model="queryParams.wcId" @keyup.enter.native="handleQuery" placeholder="请输入助手微信ID" clearable/>
            </el-form-item>
            <el-form-item label="聊天时间" prop="startTime">
              <el-date-picker v-model="chatTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
            </el-form-item>
        </div>
        <div class="from-Btn">
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
            </el-form-item>
            <el-form-item>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </div>
      </el-form>

      <el-table v-loading="loading" :data="wcLablList" :header-cell-style="{ background: '#fcfcfd', color: '#000' }" border>
        <el-table-column label="微信名称" prop="wcUserName" align="center" :show-overflow-tooltip="true"/>
        <el-table-column label="最近聊天时间" prop="lastChatTime" align="center" :show-overflow-tooltip="true" width="180">
            <template slot-scope="scope">
                <span>{{ parseTime(scope.row.lastChatTime, '{y}-{m}-{d} {h}:{i}') }}</span>
            </template>
        </el-table-column>
        <el-table-column label="微信ID" prop="wcUserId" align="center" :show-overflow-tooltip="true"/>
        <el-table-column label="所属营销助手" prop="wcName" align="center" :show-overflow-tooltip="true"/>
      </el-table>
  
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>
  
    </div>
  </template>
  
  <script>
  
  import request from '@/utils/request'
  
  export default {
    name: "WcUserLableCopy",
    data() {
      return {
        id:null,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 微信用户标签信息表格数据
        wcLablList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          wcId: null,
          wcName: null,
          tagName:this.$route.query.id,
          wcUserName: null,
          startTime: null,
          endTime: null,
        },
        chatTime:[],
      };
    },
    created() { 
    },
    mounted(){
      this.getList();
    },
    methods: {
      /** 查询微信用户标签信息列表 */
      getList() {
        this.loading = true;
        listWcLable(this.queryParams).then(res => {
          if (res['code']==200) {
            const dt = res['data'];
            this.total = dt['total'];
            //console.log(dt,dt['rows'])
            this.wcLablList = dt['rows'];
          }
          this.loading = false;
        });
        setTimeout(()=>{
          this.loading = false;
        },2000)
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.startTime=null
        this.queryParams.endTime=null
        if(this.chatTime!=''&&this.chatTime!=null){
          this.queryParams.startTime=this.chatTime[0]+' 00:00:00'
          this.queryParams.endTime=this.chatTime[1]+' 23:59:59'
        }

        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.chatTime=[]
        this.handleQuery();
      },
    }
  };
  
  /** js请求 调用 */
  
  // 查询微信用户标签信息列表
  export function listWcLable(query) {
    return request({
      url: '/skmodulemoments/wcFriendInfo/GetFriendInfo',
      method: 'post',
      params: query
    })
  }
  </script>
  <style scoped lang="scss">
   .app-container{
      background-color: #f6f9fb;
    .frominfo{
      display: flex;background-color: #fff;padding: 10px;padding-bottom: 0; margin-bottom: 20px;
      .from-item{
        display: flex;flex-wrap: wrap;
      }
      .from-Btn{
        display: flex;flex-direction: column;align-items: center;justify-content: center;width: 20%;
      }
    }
   }
  </style>